/*
Date:20220319 21:14PM
key:1.multiset删除某个key一个，m.erase(m.find(nums[i-k]));。
*/
class Solution {
public:
    vector<int> maxSlidingWindow(vector<int>& nums, int k) {
        
        
        multiset<int>m;
        vector<int>res;
        for(int i=0;i<nums.size();i++)
        {
            m.insert(nums[i]);
            if(m.size()>k)
            {
                m.erase(m.find(nums[i-k]));
            }
            if(m.size()>=k)
            {
                //cout<<i<<" ";
                res.push_back(*(m.rbegin()));
            }
            
        }
        return res;
    }
};
